<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class Form extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        //return false;
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules()
    {
        return [
            'name' => 'required|min:2|max:10',
            'pswd' => 'required|min:6',
        ];
    }

    function messages()
    {
        return [
       /*     'name.required' => '用户名不能为空',
            'name.min' => '用户名最小2位',
            'name.max' => '用户名最长10位',
            'pswd.required' => '密码不能为空',
            'pswd.min' => '密码最小6位',*/
        ];
    }

    function attributes()
    {
        return [
            'name' => '昵称',
            'pswd' => '密码',
        ];
    }
}
